#include"../../client/rpc_client.hpp"
#include<thread>

void cb(const std::string &key, const std::string&msg)
{
    std::cout << "订阅：" << key << "消息内容:" << msg << std::endl;
}

    int main()
{
    //创建一个发布客户端
    auto client = std::make_shared<rpc::client::TopicClient>("127.0.0.1",7070);
    //创建一个主题
    bool ret = client->create("hello");
    if(ret == false)
    {
        errlog("创建主题失败");
        return -1;
    }
    
    //订阅消息
    client->subscribe("hello", cb);
    
    //断开连接
    client->shutdown();

    //等待
    std::this_thread::sleep_for(std::chrono::seconds(10));
    return 0;
}